{% extends "base.html" %}

{% comment %}
<!--
  Copyright (C) 2010 ZHENG Zhong <http://www.zhengzhong.net/>
  Created on 2010-05-13.
  $Id$
-->
{% endcomment %}

{% load friday_extra %}

{#________________________________________________________________________________________________#}

{% block html_title %} Restaurants {% endblock %}

{#________________________________________________________________________________________________#}

{% block sidebar %}

  <div class="section">
    <h2>Categories:</h2>
    <ul>
      {% for category, display in categories %}
        <li><a href="{% url friday.view_restos_by_category category=category %}">{{ display|escape }}</a></li>
      {% endfor %}
    </ul>
  </div>

  <div class="section">
    <h2>Tag Cloud:</h2>
    <div id="load-resto-tag-cloud"></div>
    <script type="text/javascript">//<![CDATA[
      $(function() {
        $("#load-resto-tag-cloud").load("{% url friday.view_resto_tag_cloud %}");
      });
    //]]></script>
  </div>

  <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->

  {% if user_ and user_.is_staff %}
    <div class="section">
      <h2><a href="{% url friday.create_resto %}">Add a restaurant</a></h2>
    </div>
  {% endif %}

{% endblock %}

{#________________________________________________________________________________________________#}

{% block content %}

  <div class="section">

    <h1>Newly Added Restaurants ...</h1>

    {% with newly_added_restos as restos %}
      {% include "restos/common/restos.html" %}
    {% endwith %}

    <p><a href="{% url friday.view_all_restos %}">View all restaurants &raquo;</a></p>

  </div>

  <div class="section">

    <h1>Recent Comments ...</h1>

    {% for resto, comment in newly_commented_restos %}

      <div id="comment-{{ comment.id }}" class="post">
        <div class="user-avatar right">
          <a href="{% url friday.view_profile username=comment.author.username %}">
            <img src="{% url friday.view_avatar username=comment.author.username %}" alt="{{ comment.author|escape }}"/>
          </a>
        </div>
        <div class="post-head">
          <a href="{% url friday.view_profile username=comment.author.username %}">
            {{ comment.author|escape }}
          </a>
          commented on
          <a href="{% url friday.view_resto resto_id=resto.id %}">{{ resto|escape }}</a>
          :
        </div>
        <div class="post-body">{{ comment.content|escape|linebreaks }}</div>
        <div class="post-foot">
          <img class="icon" src="{{ static_ }}/images/comment.png" alt="Comment"/>
          Posted {{ comment.submit_date|prettify_datetime }}
        </div>
        <div class="clear"></div>
      </div>

    {% empty %}

      <p class="na">No recent comments.</p>

    {% endfor %}

  </div>

{% endblock %}

